/**
 * @Author: XXHH
 * @CreateTime: 2024-12-05
 */
class Counter2{
    private int count;
    synchronized public void add(){
        count++;
    }
    public int getCount(){
        return count;
    }
}
public class Demo20 {
    public static int count = 0;
    public static void main(String[] args) throws InterruptedException {
        Counter2 counter2 = new Counter2();
        Object locker = new Object();
        Thread t1 = new Thread(()->{
            for (int i = 0;i<50000;i++){
                synchronized (locker){
                    synchronized (locker) {
                        synchronized (locker) {
                            count++;
                        }
                    }
                }
                /*synchronized (locker){
                    counter2.add();
                }*/
            }
        });
        t1.start();
        t1.join();
        System.out.println("count:"+count);
    }
}
